﻿package blob
{
    import blob.levelstates.*;
    import org.flixel.*;

    public class GameMenu extends FlxState
    {
        private var BackBg:Class;
        private var Bg:Class;
        private var BlueStar:Class;
        private var ImgButton:Class;
        private var ImgCursor:Class;
        private var gameMusic:Class;
        private var pickedLevel:Class;
        public var levels:Array;
        public var levelName:FlxText;
        public var starsEarned:FlxGroup;

        public function GameMenu()
        {
            this.BackBg = GameMenu_BackBg;
            this.Bg = GameMenu_Bg;
            this.BlueStar = GameMenu_BlueStar;
            this.ImgButton = GameMenu_ImgButton;
            this.ImgCursor = GameMenu_ImgCursor;
            this.gameMusic = GameMenu_gameMusic;
            this.pickedLevel = GameMenu_pickedLevel;
            this.starsEarned = new FlxGroup();
            var _loc_1:* = new FlxSprite(0, 0, this.BackBg);
            add(_loc_1);
            var _loc_2:* = new FlxSprite(0, 0, this.Bg);
            add(_loc_2);
            this.loadButtons();
            this.loadText();
            return;
        }// end function

        override public function create() : void
        {
            this.levels = new Array(null, LevelState1, LevelState2, LevelState3, LevelState4, LevelState5, LevelState6, LevelState7, LevelState8, LevelState9, LevelState10, LevelState11, LevelState12, LevelState13, LevelState14, LevelState15, LevelState16, LevelState17, LevelState18, LevelState19, LevelState20);
            FlxG.mouse.show(this.ImgCursor, 2);
            var _loc_1:* = FlxG.play(this.gameMusic, 0.4, true, true);
            _loc_1.fadeIn(1);
            super.create();
            return;
        }// end function

        public function loadLevel(param1:int) : void
        {
            FlxG.mouse.hide();
            FlxG.play(this.pickedLevel);
            FlxG.switchState(new this.levels[param1]);
            return;
        }// end function

        public function loadButtons() : void
        {
            var textColor:uint;
            var level1:FlxButton;
            var level2:FlxButton;
            var level3:FlxButton;
            var level4:FlxButton;
            var level5:FlxButton;
            var level6:FlxButton;
            var level7:FlxButton;
            var level8:FlxButton;
            var level9:FlxButton;
            var level10:FlxButton;
            var level11:FlxButton;
            var level12:FlxButton;
            var level13:FlxButton;
            var level14:FlxButton;
            var level15:FlxButton;
            var level16:FlxButton;
            var level17:FlxButton;
            var level18:FlxButton;
            var level19:FlxButton;
            var level20:FlxButton;
            var i:int;
            var column1_X:int;
            var row1_Y:int;
            var row_Spacing:int;
            var row2_Y:* = row1_Y + row_Spacing;
            var row3_Y:* = row2_Y + row_Spacing;
            var row4_Y:* = row3_Y + row_Spacing;
            var row_num:int;
            var num_of_columns:int;
            var column_Spacing:int;
            textColor;
            with ({})
            {
                {}.test = function () : void
            {
                level1.exists = false;
                loadLevel(1);
                return;
            }// end function
            ;
            }
            level1 = new FlxButton(column1_X + i * column_Spacing, row1_Y, "Level " + i.toString(), function () : void
            {
                level1.exists = false;
                loadLevel(1);
                return;
            }// end function
            );
            level1.onOver = function () : void
            {
                levelName.text = Blob.level1Name;
                placeStars(FlxG.levels[1]);
                return;
            }// end function
            ;
            level1.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level1.labelOffset = new FlxPoint(-3, 41);
            level1.label.color = textColor;
            level1.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level1);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level2.exists = false;
                loadLevel(2);
                return;
            }// end function
            ;
            }
            level2 = new FlxButton(column1_X + i * column_Spacing, row1_Y, "Level " + i.toString(), function () : void
            {
                level2.exists = false;
                loadLevel(2);
                return;
            }// end function
            );
            level2.onOver = function () : void
            {
                levelName.text = Blob.level2Name;
                placeStars(FlxG.levels[2]);
                return;
            }// end function
            ;
            level2.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level2.labelOffset = new FlxPoint(-3, 41);
            level2.label.color = textColor;
            level2.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level2);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level3.exists = false;
                loadLevel(3);
                return;
            }// end function
            ;
            }
            level3 = new FlxButton(column1_X + i * column_Spacing, row1_Y, "Level " + i.toString(), function () : void
            {
                level3.exists = false;
                loadLevel(3);
                return;
            }// end function
            );
            level3.onOver = function () : void
            {
                levelName.text = Blob.level3Name;
                placeStars(FlxG.levels[3]);
                return;
            }// end function
            ;
            level3.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level3.labelOffset = new FlxPoint(-3, 41);
            level3.label.color = textColor;
            level3.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level3);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level4.exists = false;
                loadLevel(4);
                return;
            }// end function
            ;
            }
            level4 = new FlxButton(column1_X + i * column_Spacing, row1_Y, "Level " + i.toString(), function () : void
            {
                level4.exists = false;
                loadLevel(4);
                return;
            }// end function
            );
            level4.onOver = function () : void
            {
                levelName.text = Blob.level4Name;
                placeStars(FlxG.levels[4]);
                return;
            }// end function
            ;
            level4.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level4.labelOffset = new FlxPoint(-3, 41);
            level4.label.color = textColor;
            level4.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level4);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level5.exists = false;
                loadLevel(5);
                return;
            }// end function
            ;
            }
            level5 = new FlxButton(column1_X + i * column_Spacing, row1_Y, "Level " + i.toString(), function () : void
            {
                level5.exists = false;
                loadLevel(5);
                return;
            }// end function
            );
            level5.onOver = function () : void
            {
                levelName.text = Blob.level5Name;
                placeStars(FlxG.levels[5]);
                return;
            }// end function
            ;
            level5.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level5.labelOffset = new FlxPoint(-3, 41);
            level5.label.color = textColor;
            level5.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level5);
            i = (i + 1);
            row_num = 1 * num_of_columns;
            with ({})
            {
                {}.test = function () : void
            {
                level6.exists = false;
                loadLevel(6);
                return;
            }// end function
            ;
            }
            level6 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row2_Y, "Level " + i.toString(), function () : void
            {
                level6.exists = false;
                loadLevel(6);
                return;
            }// end function
            );
            level6.onOver = function () : void
            {
                levelName.text = Blob.level6Name;
                placeStars(FlxG.levels[6]);
                return;
            }// end function
            ;
            level6.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level6.labelOffset = new FlxPoint(-3, 41);
            level6.label.color = textColor;
            level6.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level6);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level7.exists = false;
                loadLevel(7);
                return;
            }// end function
            ;
            }
            level7 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row2_Y, "Level " + i.toString(), function () : void
            {
                level7.exists = false;
                loadLevel(7);
                return;
            }// end function
            );
            level7.onOver = function () : void
            {
                levelName.text = Blob.level7Name;
                placeStars(FlxG.levels[7]);
                return;
            }// end function
            ;
            level7.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level7.labelOffset = new FlxPoint(-3, 41);
            level7.label.color = textColor;
            level7.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level7);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level8.exists = false;
                loadLevel(8);
                return;
            }// end function
            ;
            }
            level8 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row2_Y, "Level " + i.toString(), function () : void
            {
                level8.exists = false;
                loadLevel(8);
                return;
            }// end function
            );
            level8.onOver = function () : void
            {
                levelName.text = Blob.level8Name;
                placeStars(FlxG.levels[8]);
                return;
            }// end function
            ;
            level8.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level8.labelOffset = new FlxPoint(-3, 41);
            level8.label.color = textColor;
            level8.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level8);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level9.exists = false;
                loadLevel(9);
                return;
            }// end function
            ;
            }
            level9 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row2_Y, "Level " + i.toString(), function () : void
            {
                level9.exists = false;
                loadLevel(9);
                return;
            }// end function
            );
            level9.onOver = function () : void
            {
                levelName.text = Blob.level9Name;
                placeStars(FlxG.levels[9]);
                return;
            }// end function
            ;
            level9.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level9.labelOffset = new FlxPoint(-3, 41);
            level9.label.color = textColor;
            level9.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level9);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level10.exists = false;
                loadLevel(10);
                return;
            }// end function
            ;
            }
            level10 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row2_Y, "Level " + i.toString(), function () : void
            {
                level10.exists = false;
                loadLevel(10);
                return;
            }// end function
            );
            level10.onOver = function () : void
            {
                levelName.text = Blob.level10Name;
                placeStars(FlxG.levels[10]);
                return;
            }// end function
            ;
            level10.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level10.labelOffset = new FlxPoint(-3, 41);
            level10.label.color = textColor;
            level10.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level10);
            i = (i + 1);
            row_num = 2 * num_of_columns;
            with ({})
            {
                {}.test = function () : void
            {
                level11.exists = false;
                loadLevel(11);
                return;
            }// end function
            ;
            }
            level11 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row3_Y, "Level " + i.toString(), function () : void
            {
                level11.exists = false;
                loadLevel(11);
                return;
            }// end function
            );
            level11.onOver = function () : void
            {
                levelName.text = Blob.level11Name;
                placeStars(FlxG.levels[11]);
                return;
            }// end function
            ;
            level11.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level11.labelOffset = new FlxPoint(-3, 41);
            level11.label.color = textColor;
            level11.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level11);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level12.exists = false;
                loadLevel(12);
                return;
            }// end function
            ;
            }
            level12 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row3_Y, "Level " + i.toString(), function () : void
            {
                level12.exists = false;
                loadLevel(12);
                return;
            }// end function
            );
            level12.onOver = function () : void
            {
                levelName.text = Blob.level12Name;
                placeStars(FlxG.levels[12]);
                return;
            }// end function
            ;
            level12.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level12.labelOffset = new FlxPoint(-3, 41);
            level12.label.color = textColor;
            level12.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level12);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level13.exists = false;
                loadLevel(13);
                return;
            }// end function
            ;
            }
            level13 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row3_Y, "Level " + i.toString(), function () : void
            {
                level13.exists = false;
                loadLevel(13);
                return;
            }// end function
            );
            level13.onOver = function () : void
            {
                levelName.text = Blob.level13Name;
                placeStars(FlxG.levels[13]);
                return;
            }// end function
            ;
            level13.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level13.labelOffset = new FlxPoint(-3, 41);
            level13.label.color = textColor;
            level13.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level13);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level14.exists = false;
                loadLevel(14);
                return;
            }// end function
            ;
            }
            level14 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row3_Y, "Level " + i.toString(), function () : void
            {
                level14.exists = false;
                loadLevel(14);
                return;
            }// end function
            );
            level14.onOver = function () : void
            {
                levelName.text = Blob.level14Name;
                placeStars(FlxG.levels[14]);
                return;
            }// end function
            ;
            level14.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level14.labelOffset = new FlxPoint(-3, 41);
            level14.label.color = textColor;
            level14.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level14);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level15.exists = false;
                loadLevel(15);
                return;
            }// end function
            ;
            }
            level15 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row3_Y, "Level " + i.toString(), function () : void
            {
                level15.exists = false;
                loadLevel(15);
                return;
            }// end function
            );
            level15.onOver = function () : void
            {
                levelName.text = Blob.level15Name;
                placeStars(FlxG.levels[15]);
                return;
            }// end function
            ;
            level15.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level15.labelOffset = new FlxPoint(-3, 41);
            level15.label.color = textColor;
            level15.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level15);
            i = (i + 1);
            row_num = 3 * num_of_columns;
            with ({})
            {
                {}.test = function () : void
            {
                level16.exists = false;
                loadLevel(16);
                return;
            }// end function
            ;
            }
            level16 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row4_Y, "Level " + i.toString(), function () : void
            {
                level16.exists = false;
                loadLevel(16);
                return;
            }// end function
            );
            level16.onOver = function () : void
            {
                levelName.text = Blob.level16Name;
                placeStars(FlxG.levels[16]);
                return;
            }// end function
            ;
            level16.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level16.labelOffset = new FlxPoint(-3, 41);
            level16.label.color = textColor;
            level16.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level16);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level17.exists = false;
                loadLevel(17);
                return;
            }// end function
            ;
            }
            level17 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row4_Y, "Level " + i.toString(), function () : void
            {
                level17.exists = false;
                loadLevel(17);
                return;
            }// end function
            );
            level17.onOver = function () : void
            {
                levelName.text = Blob.level17Name;
                placeStars(FlxG.levels[17]);
                return;
            }// end function
            ;
            level17.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level17.labelOffset = new FlxPoint(-3, 41);
            level17.label.color = textColor;
            level17.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level17);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level18.exists = false;
                loadLevel(18);
                return;
            }// end function
            ;
            }
            level18 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row4_Y, "Level " + i.toString(), function () : void
            {
                level18.exists = false;
                loadLevel(18);
                return;
            }// end function
            );
            level18.onOver = function () : void
            {
                levelName.text = Blob.level18Name;
                placeStars(FlxG.levels[18]);
                return;
            }// end function
            ;
            level18.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level18.labelOffset = new FlxPoint(-3, 41);
            level18.label.color = textColor;
            level18.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level18);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level19.exists = false;
                loadLevel(19);
                return;
            }// end function
            ;
            }
            level19 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row4_Y, "Level " + i.toString(), function () : void
            {
                level19.exists = false;
                loadLevel(19);
                return;
            }// end function
            );
            level19.onOver = function () : void
            {
                levelName.text = Blob.level19Name;
                placeStars(FlxG.levels[19]);
                return;
            }// end function
            ;
            level19.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level19.labelOffset = new FlxPoint(-3, 41);
            level19.label.color = textColor;
            level19.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level19);
            i = (i + 1);
            with ({})
            {
                {}.test = function () : void
            {
                level20.exists = false;
                loadLevel(20);
                return;
            }// end function
            ;
            }
            level20 = new FlxButton(column1_X + (i - row_num) * column_Spacing, row4_Y, "Level " + i.toString(), function () : void
            {
                level20.exists = false;
                loadLevel(20);
                return;
            }// end function
            );
            level20.onOver = function () : void
            {
                levelName.text = Blob.level20Name;
                placeStars(FlxG.levels[20]);
                return;
            }// end function
            ;
            level20.onOut = function () : void
            {
                levelName.text = "";
                hideStars();
                return;
            }// end function
            ;
            level20.labelOffset = new FlxPoint(-3, 41);
            level20.label.color = textColor;
            level20.loadGraphic(this.ImgButton, false, false, 41, 40);
            add(level20);
            i = (i + 1);
            return;
        }// end function

        public function hideStars() : void
        {
            var _loc_1:FlxSprite = null;
            for each (_loc_1 in this.starsEarned.members)
            {
                
                _loc_1.visible = false;
            }
            return;
        }// end function

        public function placeStars(param1:int) : void
        {
            var _loc_3:FlxSprite = null;
            var _loc_2:int = 0;
            for each (_loc_3 in this.starsEarned.members)
            {
                
                if (_loc_2 < param1)
                {
                    _loc_3.visible = true;
                }
                _loc_2++;
            }
            return;
        }// end function

        public function loadText() : void
        {
            var _loc_1:* = new FlxText(0, 420, 800, "Click on the Blob to select a level.");
            _loc_1.setFormat(null, 18, 16777215, "center");
            add(_loc_1);
            var _loc_2:* = new FlxText(0, 25, 800, "Level Select Menu");
            _loc_2.setFormat(null, 28, 16777215, "center");
            add(_loc_2);
            this.levelName = new FlxText(150, 475, 600);
            this.levelName.setFormat(null, 18);
            add(this.levelName);
            var _loc_3:* = new FlxSprite(260, 500, this.BlueStar);
            _loc_3.visible = false;
            var _loc_4:* = new FlxSprite(380, 500, this.BlueStar);
            new FlxSprite(380, 500, this.BlueStar).visible = false;
            var _loc_5:* = new FlxSprite(500, 500, this.BlueStar);
            new FlxSprite(500, 500, this.BlueStar).visible = false;
            this.starsEarned.add(_loc_3);
            this.starsEarned.add(_loc_4);
            this.starsEarned.add(_loc_5);
            add(this.starsEarned);
            return;
        }// end function

    }
}
